BRIDGE:=bridge

BRIDGE_BASEDIR:=$(BASEDIR)/$(BRIDGE)

BRIDGE_CC:=g++
BRIDGE_LD:=g++

BRIDGE_MODULES_DEPENDENCIES:=common mythread myfile mynet message bridgenet

BRIDGE_INCFLAGS:=-I$(BRIDGE_BASEDIR)/inc $(patsubst %, -I$(BASEDIR)/%/inc, $(BRIDGE_MODULES_DEPENDENCIES))

ifeq ($(SYSTEM), Linux)
BRIDGE_DEBUG_CFLAGS:=-g -Wall -W -Woverloaded-virtual -D_REENTRANT -DDEBUG $(BRIDGE_INCFLAGS)
BRIDGE_DEBUG_LDFLAG:=-Llib/debug -Wl,-R$(PREFIX)lib/debug 
BRIDGE_DEBUG_LIBS:=$(patsubst %, -l%, $(BRIDGE_MODULES_DEPENDENCIES)) -lpthread -lrt -lcurl

BRIDGE_RELEASE_CFLAGS:=-Wall -W -Woverloaded-virtual -D_REENTRANT -DRELEASE $(BRIDGE_INCFLAGS)
BRIDGE_RELEASE_LDFLAG:=-Llib/release -Wl,-R$(PREFIX)lib/release 
BRIDGE_RELEASE_LIBS:=$(patsubst %, -l%, $(BRIDGE_MODULES_DEPENDENCIES)) -lpthread -lrt -lcurl

endif

BRIDGE_SRC:=$(shell ls 2>&1 $(BRIDGE_BASEDIR)/src/*.cpp)

TMP_BRIDGE_OBJ:= $(patsubst %.cpp,%.o,$(filter %.cpp,$(BRIDGE_SRC)))
TMP_BRIDGE_DEP:= $(patsubst %.cpp,%.d,$(filter %.cpp,$(BRIDGE_SRC)))

SRC+=$(BRIDGE_SRC)

BRIDGE_DEBUG_OBJS=$(shell echo $(TMP_BRIDGE_OBJ) | sed -e 's@src@obj/debug@g' )
BRIDGE_RELEASE_OBJS+=$(shell echo $(TMP_BRIDGE_OBJ) | sed -e 's@src@obj/release@g' )

DEBUG_OBJS+=$(BRIDGE_DEBUG_OBJS)
RELEASE_OBJS+=$(BRIDGE_RELEASE_OBJS)

# Dependencies are release independant.
DEPS+=$(shell echo $(TMP_BRIDGE_DEP) | sed -e 's@src@dep@g' )

ifeq ($(SYSTEM), MINGW32_NT-5.1)
DEBUG_TARGETS+=$(PREFIX)bin/debug/$(BRIDGE).exe

RELEASE_TARGETS+=$(PREFIX)bin/release/$(BRIDGE)%.exe
endif

ifeq ($(SYSTEM), Linux)
DEBUG_TARGETS+=$(PREFIX)bin/debug/$(BRIDGE)
RELEASE_TARGETS+=$(PREFIX)bin/release/$(BRIDGE)
endif

